import os

print(os.path.dirname(__file__))
# 相对路径 .. 当前文件的上一级
print(os.path.isabs("aa.txt"))
print(os.path.abspath("aa.txt"))
print(os.path.abspath(__file__))
print(os.getcwd())

file = r'E:\python\my_opcua\file_test\aa.txt';
res = os.path.split(file)
print(res[1])
res = os.path.splitext(file)  # 分割文件与扩展名
print(res)

size = os.path.getsize(file)  # 获取文件大小 单位字节
print(size)

ret = os.listdir(r'E:\python\my_opcua')
print(ret)

path = r'E:\python\my_opcua\p1'
if not os.path.exists(path):
    os.mkdir(r'E:\python\my_opcua\p1')

file = r'E:\python\my_opcua\p1\a.txt'
if not os.path.exists(file):
    with open(file, mode='w') as f:

        pass
